package movie.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import movie.entity.Consumer;
import movie.service.UserUpdateService;

@Controller
public class UserUpdateController {

	@Autowired
	UserUpdateService userUpdateService;
	@RequestMapping(value = "/user_update", method = RequestMethod.GET)
	public String get() {
		return "/user/user_update";
	}
	@RequestMapping(value = "/user_update", method = RequestMethod.POST)
	public String post(Consumer consumer,HttpServletRequest request) {
		int rows = userUpdateService.update(consumer);
		HttpSession session = request.getSession();
		Consumer tmp = (Consumer)session.getAttribute("cur_user");
		tmp.setUserName(consumer.getUserName());
		tmp.setPhoneNumber(consumer.getPhoneNumber());
		return "/user/user_update";
	}
}
